#include "process.h"
#include <unistd.h>
#include <time.h>

typedef void (*callback_t)(double,double);

double SpeedFloat(double start,double range)
{
  int int_range = (int)range;
  return start + rand() % int_range + (range - int_range);
}
void DownLoad(double total,callback_t cb)
{
  srand(time(NULL));
  double cur = 0.0;
  while(cur <= total)
  {
    cb(total,cur);//更新进度,按照下载进度进行更新进度条
    cur += SpeedFloat(1.0,20.8);//模拟下载行为
    if(cur > total)
    {
      cur = total;
      cb(total,cur);
      break;
    }
    usleep(30000);
  }
}
int main()
{
  printf("download:2014.MB\n");
  DownLoad(2014,FlashProcess);

  return 0;
}
